package game.utils.collision 
{
	import starling.display.DisplayObject;
	/**
	 * ...
	 * @author Thot
	 */
	public class Collision 
	{
		
		public function Collision() 
		{
			
		}
		
		static public function hitTest( p_elements:Vector.<DisplayObject>, p_x:int, p_y:int, p_width:int, p_height:int ):Vector.<DisplayObject>
		{
			var tab:Vector.<DisplayObject> = new Vector.<DisplayObject>();
			var i:int = p_elements.length;
			var left:int = p_x;
			var top:int = p_y;
			var right:int = p_x + p_width;
			var bottom:int = p_y + p_height;
			var element:DisplayObject;
			
			while ( --i > -1 )
			{
				element = p_elements[i];
				if ( 
						element.x > right ||
						element.y > bottom ||
						element.x + element.width < left ||
						element.y + element.height < top
					)
					{
						continue;
					}
					
				tab.push(element);
			}
			
			return tab;
		}
		
	}

}